package com.itheima.d2_buffered_stream;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

/*
    目标：观察原始流和缓冲流的性能。
 */
public class TimeTest4 {
    public static void main(String[] args) throws Exception {
        long begin = System.currentTimeMillis();
        test2();
        long end=System.currentTimeMillis();
        System.out.println(end-begin);
    }
    static void test1()throws Exception {
        BufferedInputStream bis=new BufferedInputStream(new FileInputStream("aaa.txt"));

        int l;
        byte[] bytes=new byte[1024];
        while((l=bis.read(bytes))!=-1){
            System.out.println(new String(bytes,0,l));
        }
        bis.close();
    }

    static void test2() throws Exception {
        FileInputStream fis=new FileInputStream("aaa.txt");
        int l;
        byte[] bytes=new byte[3];
        while((l=fis.read(bytes))!=-1){
            System.out.println(new String(bytes,0,l));
        }
        fis.close();
    }
}










